package likou;

import java.util.Arrays;
import java.util.HashMap;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/08/06 23:32
 */
public class _473 {
    public boolean makesquare(int[] matchsticks) {
        int sum = 0;
        int len = matchsticks.length;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i : matchsticks) {
            map.merge(i, 1, Integer::sum);
            sum += i;
        }
        if (sum % 4 != 0) return false;
        Arrays.sort(matchsticks);
        int right = len - 1;
        if (matchsticks[right] > sum / 4) return false;
        int left = 0;
        int now = 0;
        int[] ok = new int[len];
        while (left < right) {
            now = sum / 4 - matchsticks[right];
            while (now!=0){
                if (map.containsKey(now));
            }
        }
        return true;
    }
}
